<template>
  <div class="wrap">
    <swiper ref="mySwiper" :options="swiperOptions">
      <swiper-slide v-for="(item, index) in bannerImg" :key="index">
        <img :src="item" alt="" class="swiper-img" />
        <div
          class="img-desc"
          data-swiper-parallax="-1600"
          data-swiper-parallax-duration="1000"
        >
          <h3>{{ bannerUrlArr[index].title }}</h3>
          <div class="info">
            {{ bannerUrlArr[index].content }}
          </div>
        </div>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "carrousel",
  data() {
    return {
      swiperOptions: {
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
        },
        autoplay: true,
        autoplay: {
          disableOnInteraction: false,
        },
        parallax: true,
        loop: true,
        // Some Swiper option/callback...
      },
      bannerImg: [
        "http://iwenwiki.com/api/blueberrypai/indexImg/banner1.jpg",
        "http://iwenwiki.com/api/blueberrypai/indexImg/banner2.jpg",
        "http://iwenwiki.com/api/blueberrypai/indexImg/banner3.jpg",
        "http://iwenwiki.com/api/blueberrypai/indexImg/banner2.jpg",
      ],
    };
  },
  props: {
    bannerUrlArr: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
  },
  mounted() {
    this.swiper.slideTo(1, 1000, false);
  },
};
</script>

<style lang="less" scoped>
.wrap {
  width: 1200px;
  margin: 0 auto;
}
.swiper-img {
  width: 100%;
  height: 500px;
}
.swiper-container {
  --swiper-pagination-color: #00ff33;
}
.img-desc {
  width: 600px;
  height: 230px;
  position: absolute;
  padding: 24px 15px;
  color: #fff;
  left: 180px;
  top: 145px;
  background: rgba(0, 0, 0, 0.5);
  h3 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 21px;
    font-weight: 700;
  }
  .info {
    line-height: 30px;
    text-indent: 2em;
    letter-spacing: 1px;
  }
}
</style>